package o;

import android.app.Activity;
import com.huawei.appgallery.agreement.api.ui.ITermsActivityProtocol;
import com.huawei.appgallery.agreement.api.ui.IUpgradeActivityProtocol;
import java.util.List;
import o.ayb.e;

public class ayg implements ayi, ayd {
    private String ˊ = aya.ˏ(this);
    private final awn ˋ;
    private final awo ˎ;
    private String ˏ;
    private final Activity ॱ;

    public ayg(Activity activity, awn o_awn, awo o_awo) {
        this.ॱ = activity;
        this.ˋ = o_awn;
        this.ˎ = o_awo;
    }

    private void ˏ() {
        this.ˏ = ays.ˊ();
        aye o_aye = new aye();
        o_aye.ˏ(this);
        o_aye.ˋ();
    }

    public void ˋ() {
        if (ayn.ͺ()) {
            awg.ˎ.ˏ("CheckNewAgreementShowTask", "service is stopped, do not query or report.");
        } else if (ayn.ˊ() || !ayn.ʻ()) {
            awg.ˎ.ˋ("CheckNewAgreementShowTask", "query after login successful.");
            ˏ();
        } else {
            awg.ˎ.ˋ("CheckNewAgreementShowTask", "report after login successful, the last report failed.");
            ayf o_ayf = new ayf(true);
            o_ayf.ॱ(new awl(this) {
                final /* synthetic */ ayg ˋ;

                {
                    this.ˋ = r1;
                }

                public void ˏ(boolean z, boolean z2) {
                    awg.ˎ.ˋ("CheckNewAgreementShowTask", "query after reporting, isSignedForUser: , isReportOK: " + z2);
                    this.ˋ.ˏ();
                }
            });
            o_ayf.ˊ();
        }
    }

    public void ॱ() {
        boolean ᐝ = ayn.ᐝ();
        awg.ˎ.ˋ("CheckNewAgreementShowTask", "onError, isSignedForUserCheckSignTime: " + ᐝ + ", Activity: " + this.ॱ);
        if (ᐝ) {
            ॱ(false);
        } else {
            ˊ();
        }
    }

    public void ˊ() {
        awg.ˎ.ˋ("CheckNewAgreementShowTask", "onNotSigned, Activity: " + this.ॱ);
        ayn.ˏ(this.ˏ, false);
        axi.ˋ(1);
        this.ˋ.ॱ(this.ॱ);
        if (!ActivityUtil.isAcitivtyNotValid(this.ॱ)) {
            aya.ˎ().ˎ(this.ˊ, this);
            fjb ॱ = bkt.ॱ("Agreement", "AgreementSignActivity");
            ITermsActivityProtocol iTermsActivityProtocol = (ITermsActivityProtocol) ॱ.ˊ();
            iTermsActivityProtocol.setDialogId(this.ˊ);
            iTermsActivityProtocol.setSignForUser(true);
            fiu.ˊ().ˏ(this.ॱ, ॱ);
        }
    }

    public void ˋ(List<Integer> list) {
        awg.ˎ.ˋ("CheckNewAgreementShowTask", "onUpgrade, Activity: " + this.ॱ);
        ayn.ˎ((Integer[]) list.toArray(new Integer[0]));
        ayn.ˏ(this.ˏ, false);
        axi.ˋ(2);
        this.ˋ.ˋ(this.ॱ);
        if (!ActivityUtil.isAcitivtyNotValid(this.ॱ)) {
            aya.ˎ().ˎ(this.ˊ, this);
            fjb ॱ = bkt.ॱ("Agreement", "AgreementUpgradeActivity");
            ((IUpgradeActivityProtocol) ॱ.ˊ()).setDialogId(this.ˊ);
            fiu.ˊ().ˏ(this.ॱ, ॱ);
        }
    }

    public void ॱ(boolean z) {
        awg.ˎ.ˋ("CheckNewAgreementShowTask", "onSigned, isQueryResult: " + z + ", Activity: " + this.ॱ);
        String ˊ = ays.ˊ();
        if (ˊ.equals(this.ˏ)) {
            if (z) {
                ayn.ˏ(this.ˏ, true);
            }
            this.ˋ.ˎ(this.ॱ);
            if (this.ˎ != null) {
                this.ˎ.ˋ(true);
                return;
            }
            return;
        }
        awg.ˎ.ˋ("CheckNewAgreementShowTask", "query again, country is changed: " + this.ˏ + " -> " + ˊ);
        ˏ();
    }

    public void ˎ(String str, int i, boolean z) {
        awg.ˎ.ˋ("CheckNewAgreementShowTask", "onDialogResult,  dialogId = " + str + " observerKey = " + this.ˊ + " action = " + i + " result = " + z);
        if (!dof.ॱ(str) && str.equals(this.ˊ)) {
            aya.ˎ().ˎ("CheckNewAgreementShowTask" + hashCode());
            awg.ˎ.ˋ("CheckNewAgreementShowTask", "onDialogResult, action: " + i + ", result: " + z);
            if (i == e.ˏ.ordinal() && z) {
                awg.ˎ.ˋ("CheckNewAgreementShowTask", "query again, user retry.");
                ˏ();
                return;
            }
            ayn.ˎ(this.ˏ, z);
            ayn.ˏ(this.ˏ, z);
            if (this.ˎ != null) {
                awg.ˎ.ˋ("CheckNewAgreementShowTask", "onDialogResult, fire signCallback: " + z);
                this.ˎ.ˋ(z);
            }
        }
    }
}
